<?php
/* @var $this InvoiceController */
/* @var $model Invoice */
/* @var $form CActiveForm */
?>

<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'invoice-form',
	// Please note: When you enable ajax validation, make sure the corresponding
	// controller action is handling ajax validation correctly.
	// There is a call to performAjaxValidation() commented in generated controller code.
	// See class documentation of CActiveForm for details on this.
	'enableAjaxValidation'=>false,
)); 
?>

	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<?php echo $form->errorSummary($model); ?>

	<div class="row">
		<?php echo $form->labelEx($model,'invoice_no'); ?>
		<?php echo $form->textField($model,'invoice_no',array('size'=>50,'maxlength'=>50,'readonly'=>'readonly','value'=>$tempValue['lastSO'])); ?>
		<?php echo $form->error($model,'invoice_no'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'date_invoice'); ?>
		<?php echo $form->textField($model,'date_invoice',array('value'=>date("Y-m-d"),'readonly'=>'readonly')); ?>
		<?php echo $form->error($model,'date_invoice'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'currency'); ?>
		<?php //echo $form->dropDownList($model,'currency',array('USD'=>'USD','IDR'=>'IDR')); ?>
		<?php echo $form->dropDownList($model,'currency',array('USD'=>'USD','IDR'=>'IDR'),
			    array(
			    'prompt'=>'Select Currency',
			    'ajax' => array(
			    'type'=>'POST', //request type
			    'url'=>Controller::createUrl('bankAccount/listBank'), //url to call.
			    'update'=>'#Invoice_account_id', //selector to update
			    'data'=>array('currency' => 'js:this.value'), 

			    ))); 
        ?>
		<?php echo $form->error($model,'currency'); ?>
	</div>
	
	<div class="row">
		<?php echo $form->labelEx($model,'account_id'); ?>
		<!-- <div id='account_id'> -->
		<?php  echo $form->dropDownList($model, 'account_id', array('prompt'=>'Select Account'/*,'id'=>'account_id'*/)); 
			//echo CHtml::dropDownList('Invoice[account_id]','', array());
		?>
		<!-- </div> -->
		<?php echo $form->error($model,'account_id'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'due_date'); ?>
		<?php echo $form->numberField($model,'due_date',array('id'=>'due_date','placeholder'=>'-','min'=>1,'max'=>999)); ?>
		<div id='result_due_date'><?= Date('Y-m-d')?></div>
		<?php echo $form->error($model,'due_date'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'PO_reference'); ?>
		<?php $this->widget('ext.yii-easyui.widgets.EuiCombogrid', array(
			'id'=>'PO_ref',
			//'name'=>'quotation_no',			
			'style' => 'width: 220px',
			'panelWidth' => 450,
			'pagination' => true,
			'url' => $this->createUrl('purchase'),
			'idField' => 'PO_ref',
			'textField' => 'PO_ref',
			'columns' => array(
				array('title' => 'Quotation no', 'field'=>'quotation_no', 'width'=> 20, 'sortable'=>true),
				array('title' => 'PO Reference', 'field'=>'PO_ref', 'width'=> 20, 'sortable'=>true),
			)	
		)); 
		echo $form->hiddenField($model,'PO_reference',array('id'=>'po_ref'));
		?>
		<?php echo $form->error($model,'PO_reference'); ?>
	</div>

	<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save', array('id'=>'submitBtn')); ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->

<?php
$test='2014-12-07';
//$test2=strtotime("+");*/
$test2=date("Y-m-d",strtotime("$test +11 days"));
echo $test2;
?>